#!/bin/bash
# The .app's Contents/MacOS path contains a space ("BQT Presence.app") and, under App Translocation,
# is read-only. So: (1) detect Apple Silicon via sysctl (uname -m lies "x86_64" under Rosetta, which
# picked the wrong binary); (2) the binaries are already +x from build time; (3) open a space-safe
# .command wrapper (path escaped via %q) written to the writable home dir — Terminal runs .command files.
DIR="$(cd "$(dirname "$0")" && pwd)"
if [ "$(sysctl -n hw.optional.arm64 2>/dev/null)" = "1" ]; then BIN="$DIR/bqt-presence-macos-arm64"; else BIN="$DIR/bqt-presence-macos"; fi
RUN="$HOME/.bqt-presence-run.command"
printf '#!/bin/bash\nclear\nexec %q\n' "$BIN" > "$RUN"
chmod +x "$RUN"
open "$RUN"
